﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for ScheduleComparer
/// </summary>
public class ScheduleComparer : IComparer<Schedule> {
	public int Compare(Schedule a, Schedule b) {

        int result = a.User.CompareTo(b.User);
        if (result == 0)
        {
            result = a.DayOfWeek.CompareTo(b.DayOfWeek);
            if (result == 0)
            {
                result = a.DepartureHour - b.DepartureHour;
                if (result == 0)
                {
                    result = a.ReturnHour - b.ReturnHour;
                }
            }
        }

        return result;

	}
}
